package com.example.statemachine;

import com.example.statemachine.event.PaymentEvent;
import com.example.statemachine.status.PaymentStatus;

import java.util.Objects;

/**
 * 支付领域域服务
 * 案例来源：https://juejin.cn/post/7321569896453521419
 */
public class PaymentDomainServiceImpl {

    /**
     * 支付结果通知
     */
    public void createOrder() {
        PaymentStatus targetStatus = PaymentStatus.getTargetStatus(PaymentStatus.INIT, PaymentEvent.PAY_PROCESS);
        System.out.println(targetStatus);
        if (Objects.nonNull(targetStatus)) {
            System.out.println("dbStatus: " + targetStatus.getStatus());
        }
    }

    public static void main(String[] args) {
        PaymentDomainServiceImpl p = new PaymentDomainServiceImpl();
        p.createOrder();
    }
}
